//package com.lxt.cloud.service.impl;
//
//import com.lxt.cloud.entity.MyUserDetails;
//import com.lxt.cloud.entity.User;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.security.core.userdetails.UsernameNotFoundException;
//
//import java.util.HashSet;
//import java.util.Optional;
//import java.util.Set;
//
//
//public class MyUserService implements UserDetailsService {
//
//    private final static Set<User> users = new HashSet<>();
//
//    static {
//        users.add(new User(1L, "test-user1", "123451"));
//        users.add(new User(2L, "test-user2", "123452"));
//        users.add(new User(3L, "test-user3", "123453"));
//        users.add(new User(4L, "test-user4", "123454"));
//    }
//
//    @Override
//    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
//        Optional<User> user = users.stream()
//                .filter((u) -> u.getUserName().equals(s))
//                .findFirst();
//        if (!user.isPresent())
//            throw new UsernameNotFoundException("there's no user founded!");
//        else
//            return UserDetailConverter.convert(user.get());
//    }
//
//    private static class UserDetailConverter {
//        static UserDetails convert(User user) {
//            return new MyUserDetails(user);
//        }
//    }
//}